// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
 
  if (event.action == "change") {
    return await cloud.database().collection('clinicInfo').doc("28ee4e3e6049826109fd4d574fd27b03").set({
        data: {
          clinicName: event.clinicName,
          clinicTime: event.clinicTime,
          clinicPhone: event.clinicPhone,
          clinicAddress: event.clinicAddress,
          clinicLongitude: event.clinicLongitude,
          clinicLatitude: event.clinicLatitude,
          clinicDescription: event.clinicDescription
        }
      })
      .then(res => {
        return res
      }).catch(res => {
        return res
      })
  } else if (event.action == "find") {
    return await cloud.database().collection('clinicInfo').get()
      .then(res => {
        return res
      }).catch(res => {
        return res
      })
  }
}